<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
       
    </style>
</head>
<body>
    <input id="btn" type="button" value="点击生成表格">
    <input type="text" id="row">
    <input type="text" id="col">
    <table border="1" id="table"></table>

</body>
<script>
    var row = document.getElementById("row")
    var col = document.getElementById("col")
    var btn = document.getElementById("btn")
    var table = document.getElementById("table")

    

    btn.onclick = function()
    {
        var str = "";
        var r = row.value - 0;
        var c = col.value - 0;
        
        for( var i = 0 ; i < r ; i++)
        {
            var tds = "";
            for(var j = 0 ; j < c ; j++)
            {
                tds += "<td>"+ "data" + "</td>"
            }
            str += "<tr>" + tds + "</tr>"
        }
        table.innerHTML = str;
    }
</script>
</html>